#include<iostream>

using std::cin,std::cout,std::iostream;

const int MAX_COLOR = 50+5;

int price,color,n,k,p,last_coffee_shop,last_hotel[MAX_COLOR],left_hotel_num[MAX_COLOR],cnt_hotel_num[MAX_COLOR],ans;

int main(){
    iostream::sync_with_stdio(false),cin.tie(0),cout.tie(0);

    cin>>n>>k>>p;

    for(int i=1;i<=n;i++){
        cin>>color>>price;

        if(price<=p){
            last_coffee_shop = i;
        }

        if(last_hotel[color] <= last_coffee_shop){
            left_hotel_num[color] = cnt_hotel_num[color];
        }

        last_hotel[color]=i;
        ans+=left_hotel_num[color];
        cnt_hotel_num[color]++;
    }

    cout<<ans<<"\n";
}